package cn.TreeMenu.contoller;


import cn.TreeMenu.entity.Do.Treemenu;
import cn.TreeMenu.service.impl.TreeMenuService;
import cn.entity.Status;
import cn.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/admin/Tree")
public class TreeMenuContoller {
    @Autowired
    private TreeMenuService treeMenuService;

    @ResponseBody
    @GetMapping("/Menu")
    public Status Menu(HttpSession session){
        Status status = new Status();
        User user = (User) session.getAttribute("user");
        List<Treemenu> treemenus = treeMenuService.selectTreeMenu(user.getPower());
        if (treemenus != null) {
            status.setFlag(true);
            status.setData(treemenus);
            return status;
        }else {
            status.setFlag(false);
            status.setMessage("错误");
            return status;
        }
    }
}
